package ${package}.${moduleName}.controller;

import com.quick.develop.framework.common.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import ${package}.framework.common.utils.PageResult;
import ${package}.framework.common.utils.Result;
import ${package}.${moduleName}.convert.${ClassName}Convert;
import ${package}.${moduleName}.entity.${ClassName}Entity;
import ${package}.${moduleName}.service.${ClassName}Service;
import ${package}.${moduleName}.query.${ClassName}Query;
import ${package}.${moduleName}.vo.${ClassName}VO;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * ${tableComment}
 *
 * @author ${author} ${email}
 * @since ${version} ${date}
 */
@RestController
@RequestMapping("${moduleName}/${functionName}")
@Tag(name = "${tableComment}")
@AllArgsConstructor
public class ${ClassName}Controller {

    private final ${ClassName}Service ${className}Service;

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<${ClassName}VO>> page(${ClassName}Query query) {
        PageResult<${ClassName}VO> page = ${className}Service.page(query);

        return Result.ok(page);
    }

    @GetMapping("{id}")
    @Operation(summary = "信息")
    public Result<${ClassName}VO> get(@PathVariable("id") String id) {
        ${ClassName}Entity entity = ${className}Service.getById(id);

        return Result.ok(${ClassName}Convert.INSTANCE.convert(entity));
    }

    @PostMapping
    @Operation(summary = "保存")
    public Result<String> save(@RequestBody ${ClassName}VO vo) {
        ${className}Service.save(vo);

        return Result.ok();
    }

    @PutMapping
    @Operation(summary = "修改")
    public Result<String> update(@RequestBody ${ClassName}VO vo) {
        ${className}Service.update(vo);

        return Result.ok();
    }

    @DeleteMapping
    @Operation(summary = "删除")
    public Result<String> delete(@RequestBody List<String> idList) {
        ${className}Service.delete(idList);

        return Result.ok();
    }

    @PostMapping(value = "export")
    @Operation(summary = "导出数据")
    public Result<?> dynamicExportExcel(@RequestBody ${ClassName}Query query) {
        ${className}Service.dynamicExportExcel(query);

        return Result.ok();
    }

    @PostMapping(value = "import")
    @Operation(summary = "导出数据")
    public Result<?> dynamicImportExcel(@RequestParam(value = "file") MultipartFile file) {
        ${className}Service.dynamicImportExcel(file);

        return Result.ok();
    }

    @GetMapping(value = "business/{businessKey}")
    @Operation(summary = "获取数据详情，根据业务Key")
    public Result<${ClassName}VO> get${ClassName}ByBusinessKey(@PathVariable(value = "businessKey") String businessKey) {
        return Result.ok(${className}Service.get${ClassName}ByBusinessKey(businessKey));
    }

    @PostMapping(value = "batch/update")
    @Operation(summary = "批量更新数据")
    public Result<?> batchUpdate(@RequestBody List<${ClassName}VO> list) {
        ${className}Service.batchUpdateById(list);
        return Result.ok();
    }

    @Operation(summary = "批量创建数据")
    @PostMapping(value = "batch/create")
    public Result<?> batchCreate(@RequestBody List<${ClassName}VO> list) {
        ${className}Service.batchSave(list);
        return Result.ok();
    }

    @Operation(summary = "根据Key（自定义）查询数据列表)")
    @GetMapping(value = "keys")
    public Result<List<${ClassName}VO>> getListByKeys(${ClassName}Query query) {
        ${className}Service.getListByKeys(query);
        return Result.ok();
    }
}